#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define N 10000
#define INF 2e9
int st,ans;

struct Range
{
    int L;
    int R;
}range[N];

int mycmp(const void *a,const void *b)
{
    struct Range *sa=(struct Range *)a;
    struct Range *sb=(struct Range *)b;
    if(sa->L<sb->L)return -1;
    if(sa->L>sb->L)return 1;
    return 0;
}


int main(void) {
    int n,m;
    while(scanf("%d",&n)!=EOF) {
        scanf("%d", &m);
        for (int i = 0; i < n; i++) {
            scanf("%d%d", &range[i].L, &range[i].R);
        }
        qsort(range, n, sizeof(struct Range), mycmp);
        ans = 0;
        st = 0;
        bool succ = false;
        for (int i = 0; i < n; i++) {
            int j = i, r = -INF;
            while (j < n && range[j].L <= st) {
                if (r < range[j].R) {
                    r = range[j].R;
                }
                j++;
            }
            if (r < 0) {
                ans = -1;
                break;
            }
            ans++;
            if (r >= m) {
                succ = true;
                break;
            }
            st = r;
            i = j - 1;
        }
        if (!succ) {
            printf("wrong!\n\n");
        } else {
            printf("the answer is %d", ans);
        }
    }
    return 0;
}
